{% extends './layout.html' %} {% block title %} {{ title }} {% endblock %} {% block body %}
<div class="layout_cont">
	<form class="layui-form" action="" layui-filter="chapterForm">
		<div class="layui-form-item">
			<label class="layui-form-label">章节标题</label>
			<div class="layui-input-block">
				<input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入标题" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit lay-filter="edit">立即提交</button>
				<button type="button" class="layui-btn layui-btn-primary" id="editReturn">返回</button>
			</div>
		</div>
	</form>
</div>
{% endblock %} {% block scripts %}
<script type="text/javascript">
	layui.use(['form'], function() {
		var socket = new WebSocket('ws://127.0.0.1:4000/spider');
		var $ = layui.jquery;
		var form = layui.form;
		
		$('[name="title"]').val('{{title}}');
		socket.onopen = function(){
			console.log('_connect');
		}
		/*socket.addEventListener('open', function (event) {
		    ws.send('Hello Server!');
		});
		socket.addEventListener('message', function (event) {
		    console.log('Message from server', event.data);
		});*/
		//监听提交
		/*form.on('submit(edit)', function(data) {
			var socket = new WebSocket('ws://127.0.0.1:4000/spider');
			socket.addEventListener('open', function (event) {
			    ws.send('Hello Server!');
			});
			socket.addEventListener('message', function (event) {
			    console.log('Message from server', event.data);
			});
			//socket.send('123123123');
			console.log(socket);
			return false;
		});*/
	});
</script>
{% endblock %}